Imports SpeechLib

Public Class frmBatMon
    Dim voice
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click

        Dim remaining As String
        Dim ps As PowerStatus = SystemInformation.PowerStatus
        Dim stat As String
        Dim ts As New TimeSpan(0, 0, ps.BatteryLifeRemaining)
        Dim talk As String

        If ts.TotalSeconds < 1 Then
            remaining = "Unlimited"
        Else
            remaining = ts.ToString
        End If
        stat = ps.BatteryChargeStatus.ToString
        voice = New SpVoice()

        lblAc.Text = "AC-Power: " & ps.PowerLineStatus.ToString
        lblStaus.Text = "Status: " & stat
        lblRemaining.text = "Remaining: " & ps.BatteryLifePercent * 100 & "%"
        lblLife.text = "Time Left: " & remaining

        talk = "AC Power is " & ps.PowerLineStatus.ToString & ", Battery status is " & stat & ", and the battery is at " & ps.BatteryLifePercent * 100 & "% charge, there is an estimate of " & remaining & " battery life remaining"

        If CheckBox1.Checked = True Then
            voice.speak(talk)
        End If

    End Sub

    Private Sub frmBatMon_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
        MsgBox(Me.Location.ToString)
    End Sub

End Class

